<?php
    include "DB.php";
    if (isset($_GET['id']))
    {
        $id = $_GET['id'];
    }
    
    $result = mysql_query("SELECT title,time,id FROM NEWS WHERE type = $id GROUP BY ID DESC LIMIT 0,6 ");
    while ( $row = mysql_fetch_row($result))
    {
        $i = 50;
        $title = $row[0];
        $id1 = $row[2];
        $length = strlen($title);
        $showTitle = substr($title,0, $i - intval($length));
        while (substr($showTitle, -1) != ' ')
        {
            $i = $i - 1;
            $showTitle = substr($title,0, $i - intval($length));
        }
        $showTitle = $showTitle.'...';
        $time = date("d/m",strtotime($row[1]));
        if ($length > $i) {
            echo "<a class='btn' title='$title' href='javascript: Index_ChooseNews($id1);' >$showTitle  ($time)</a>";
        }
        else {
            echo "<a class='btn' title='$title' href='javascript: Index_ChooseNews($id1);' >$title  ($time)</a>"; 
        }
    }
    
?>
